package exam.test11.q2;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class PersonTest {
     // Implement your test cases
    // Hint: The java.lang.Integer.intValue() is an inbuilt method in Java that returns the value of an Integer as an int.

    // ########## YOUR CODE STARTS HERE ##########
    //To test the `calcInsurancePrice()` method, which returns void, you can use the `getHealthInsurancePrice()` method, for example:
    //Person p = new Person("XYZ", 10, "XYZ", true, true);
    //assertEquals(0, p.getHealthInsurancePrice().intValue());

    // ########## YOUR CODE ENDS HERE ##########

    @Test(timeout = 1000)
    public void testBuildOddNumber() {
        Person person = new Person("Join", 10, "Student", true, true);
        person.setId(1);

        assertEquals(1, (long) person.getId());
        assertEquals("Join", person.getName());
        assertEquals(10, (long) person.getAge());
        assertEquals("Student", person.getOccupation());
        assertTrue(person.getDiabetes());
        assertTrue(person.getHeartDisease());
    }

    @Test(timeout = 1000)
    public void testCalcInsurancePrice() {
        Person person = new Person("Join", 10, "student", true, true);
        person.setId(1);

        person.calcInsurancePrice();
        assertEquals(350, (long) person.getHealthInsurancePrice());

        person.occupation = null;
        person.calcInsurancePrice();
        assertEquals(200, (long) person.getHealthInsurancePrice());

        person.occupation = "";
        person.calcInsurancePrice();
        assertEquals(200, (long) person.getHealthInsurancePrice());

        person.occupation = "policeman";
        person.calcInsurancePrice();
        assertEquals(200, (long) person.getHealthInsurancePrice());

        person.age = 50;
        person.heartDisease = true;
        person.diabetes = true;
        person.calcInsurancePrice();
        assertEquals(1100, (long) person.getHealthInsurancePrice());

        person.heartDisease = false;
        person.diabetes = false;
        person.calcInsurancePrice();
        assertEquals(360, (long) person.getHealthInsurancePrice());

        person.heartDisease = true;
        person.diabetes = false;
        person.calcInsurancePrice();
        assertEquals(500, (long) person.getHealthInsurancePrice());

        person.heartDisease = false;
        person.diabetes = true;
        person.calcInsurancePrice();
        assertEquals(400, (long) person.getHealthInsurancePrice());
    }

}
